﻿using System;
using System.Windows;
using System.Windows.Data;

namespace Rio.Framework.Pages.AppCode.Helpers.Converter
{
    public class VersionItemToStyleConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            object returnValue = value;
            if (parameter == null)
            {
                return false;
            }

            switch (((string)parameter).ToLowerInvariant())
            {
                case "bold":
                    returnValue = ((bool)value) ? FontWeights.Bold : FontWeights.Normal;
                    break;
                case "italic":
                    returnValue = ((bool)value) ? FontStyles.Italic : FontStyles.Normal;
                    break;
                case "margin":
                    int minorVersion = System.Convert.ToInt32(value);
                    returnValue = minorVersion == 0 ? new Thickness(0, 0, 0, 0) : new Thickness(10, 0, 0, 0);
                    break;
                default:
                    break;
            }

            return returnValue;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
